<?php

/**
 * Description of VirtualLabs_Rest_Util
 *
 * @author markos
 */
class VirtualLabs_Rest_Util {

    const STOP_VM_CMD = 'org.apache.cloudstack.api.command.user.vm.StopVMCmd';
    const START_VM_CMD = 'org.apache.cloudstack.api.command.user.vm.StartVMCmd';
    
    public function listCapacity() {
        $url = array();
        $url["response"] = "json";
        $url["command"] = "listCapacity";
        $config = new Zend_Config_Ini(CLOUDSTACK_CONFIG_FILE, APPLICATION_ENV);
        $url["zoneid"] = $config->get("zone_id");
        $v = new VirtualLabs_Rest_HttpClient_Client();
        $response = $v->call($url);

        $listCapacityResponse = Zend_Json_Decoder::decode($response);

        return $listCapacityResponse;
    }

    /**
     * Check an asynchronous job status by the $jobid
     * 
     * @param string $id Job id to verify
     * @return mixed $jobStatus An array with the information about the job.
     */
    public function jobStatus($id) {
        $url = array();
        $url["response"] = "json";
        $url["command"] = "queryAsyncJobResult";
        $url["jobid"] = $id;
        $v = new VirtualLabs_Rest_HttpClient_Client();
        $response = $v->call($url);

        $jobIdStatusResponse = Zend_Json_Decoder::decode($response);

        return $jobIdStatusResponse;
    }

}

?>
